;/******************************************************************************
; * @Filename     : startup_RC2412.s
; * @Version      : V1.0
; * @Subversion   : $
; * @Last modified: 02/20/2020 9:30:29
; *
; * @Brief        : CMSIS ARM Cortex-M0 Core Device Startup File
; *
; * Copyright (C) 2022 SKYRELAY Technology co.,Ltd All rights reserved.
;*****************************************************************************/


; <h> Stack Configuration
;   <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
    IF :LNOT: :DEF: Stack_Size
Stack_Size      EQU     0x00000500
    ENDIF
                AREA    STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem       SPACE   Stack_Size
__initial_sp


; <h> Heap Configuration
;   <o>  Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
    IF :LNOT: :DEF: Heap_Size
Heap_Size       EQU     0x00000000
    ENDIF
                AREA    HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
Heap_Mem        SPACE   Heap_Size
__heap_limit


                PRESERVE8
                THUMB



; Vector Table Mapped to Address 0 at Reset

                AREA    RESET, DATA, READONLY
                EXPORT  __Vectors

__Vectors       DCD     __initial_sp              ; Top of Stack
                DCD     Reset_Handler             ; Reset Handler
                DCD     NMI_Handler               ; NMI Handler
                DCD     HardFault_Handler         ; Hard Fault Handler
                DCD     0                         ; Reserved
                DCD     0                         ; Reserved
                DCD     0                         ; Reserved
                DCD     0                         ; Reserved
                DCD     0                         ; Reserved
                DCD     0                         ; Reserved
                DCD     0                         ; Reserved
                DCD     SVC_Handler               ; SVCall Handler
                DCD     0                         ; Reserved
                DCD     0                         ; Reserved
                DCD     PendSV_Handler            ; PendSV Handler
                DCD     SysTick_Handler           ; SysTick Handler

                ; External Interrupts
                DCD     GPIO_IRQHandler            ; GPIO interrupt  
                DCD     GPIO_E0_IRQHandler         ; GPIO interrupt  
                DCD     GPIO_E1_IRQHandler         ; GPIO interrupt
                DCD     USCI0_IRQHandler           ; USCI0 interrupt
                DCD     USCI1_IRQHandler           ; USCI1 interrupt
                DCD     USCI2_IRQHandler           ; USCI2 interrupt
                DCD     USCI3_IRQHandler           ; USCI3 interrupt
                DCD     BBE_IRQHandler              ; BB interrupt
                DCD     WDT_IRQHandler             ; Watch Dog Timer interrupt
                DCD     RTC0_IRQHandler            ; RTC0 interrupt
                DCD     QSPI0_IRQHandler           ; QSPI0 interrupt
                DCD     QSPI1_IRQHandler           ; QSPI1 interrupt				
                DCD     TMRA_IRQHandler            ; Timer A interrupt    
                DCD     TMRB0_IRQHandler           ; Timer B0 interrupt
                DCD     TMRB1_IRQHandler           ; Timer B1 interrupt  
                DCD     TMRB2_IRQHandler           ; Timer B2 interrupt 
                DCD     TMRB3_IRQHandler           ; Timer B3 interrupt 
                DCD     RTC1_IRQHandler            ; RTC1 interrupt
                DCD     0            ;
                DCD     0            ;
                DCD     0            ; 
                DCD     0            ;
                DCD     0            ; 
                DCD     0            ;
                DCD     0            ; 
                DCD     0            ; 
                DCD     0            ; 
                DCD     0            ; 
                DCD     0            ; 
                DCD     0            ; 
                DCD     0            ;
                AREA    |.text|, CODE, READONLY


; Reset Handler

Reset_Handler   PROC
                EXPORT  Reset_Handler             [WEAK]
                IMPORT  __main
                LDR     R0, =__main
                BX      R0
                ENDP


; Dummy Exception Handlers (infinite loops which can be modified)

NMI_Handler     PROC
                EXPORT  NMI_Handler               [WEAK]
                B       .
                ENDP
HardFault_Handler\
                PROC
                EXPORT  HardFault_Handler         [WEAK]
                B       .
                ENDP
SVC_Handler     PROC
                EXPORT  SVC_Handler               [WEAK]
                B       .
                ENDP
PendSV_Handler  PROC
                EXPORT  PendSV_Handler            [WEAK]
                B       .
                ENDP
SysTick_Handler PROC
                EXPORT  SysTick_Handler           [WEAK]
                B       .
                ENDP

Default_Handler PROC
                EXPORT  GPIO_IRQHandler        [WEAK]
                EXPORT  GPIO_E0_IRQHandler     [WEAK]
                EXPORT  GPIO_E1_IRQHandler     [WEAK]
                EXPORT  USCI0_IRQHandler       [WEAK]
                EXPORT  USCI1_IRQHandler       [WEAK]
                EXPORT  USCI2_IRQHandler       [WEAK]
                EXPORT  USCI3_IRQHandler       [WEAK]
                EXPORT  BBE_IRQHandler          [WEAK]
                EXPORT  WDT_IRQHandler         [WEAK]
                EXPORT  RTC0_IRQHandler         [WEAK]
				EXPORT  QSPI0_IRQHandler       [WEAK]
				EXPORT  QSPI1_IRQHandler       [WEAK]
                EXPORT  TMRA_IRQHandler        [WEAK]
                EXPORT  TMRB0_IRQHandler       [WEAK]
                EXPORT  TMRB1_IRQHandler       [WEAK]
                EXPORT  TMRB2_IRQHandler       [WEAK]
                EXPORT  TMRB3_IRQHandler       [WEAK]
                EXPORT  RTC1_IRQHandler        [WEAK]

GPIO_IRQHandler     
GPIO_E0_IRQHandler 
GPIO_E1_IRQHandler 
USCI0_IRQHandler    
USCI1_IRQHandler     
USCI2_IRQHandler     
USCI3_IRQHandler     
BBE_IRQHandler       
WDT_IRQHandler       
RTC0_IRQHandler        
QSPI0_IRQHandler    
QSPI1_IRQHandler    
TMRA_IRQHandler      
TMRB0_IRQHandler      
TMRB1_IRQHandler      
TMRB2_IRQHandler      
TMRB3_IRQHandler
RTC1_IRQHandler

                B       .

                ENDP


                ALIGN


; User Initial Stack & Heap

                IF      :DEF:__MICROLIB

                EXPORT  __initial_sp
                EXPORT  __heap_base
                EXPORT  __heap_limit

                ELSE

                IMPORT  __use_two_region_memory
                EXPORT  __user_initial_stackheap
__user_initial_stackheap

                LDR     R0, =  Heap_Mem
                LDR     R1, = (Stack_Mem + Stack_Size)
                LDR     R2, = (Heap_Mem +  Heap_Size)
                LDR     R3, = Stack_Mem
                BX      LR

                ALIGN

                ENDIF


                END
